package com.woniuxy.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

@Configuration
public class RedisConfig extends RedisTemplate<String,Object> {

    public RedisConfig(RedisConnectionFactory redisConnectionFactory){
        this.setKeySerializer(RedisSerializer.string());
        this.setValueSerializer(RedisSerializer.string());
        this.setHashKeySerializer(RedisSerializer.json());
        this.setHashValueSerializer(RedisSerializer.json());
        this.setConnectionFactory(redisConnectionFactory);
        this.afterPropertiesSet();
    }
}
